﻿using GKQC.Common;
using GKQC.DbHelper.ViewModels;
using GKQC.Machine;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AutoTester
{
    public partial class Form1 : QcFormBase
    {
        public Form1()
        {
            InitializeComponent();
            SubFormList = new List<Form>();
            Settings.CreateSettingFile();
        }

        private void tsmCom_Click(object sender, EventArgs e)
        {
            try
            {
                GKQC.Machine.FormComSet f = new GKQC.Machine.FormComSet(null);
                f.ShowDialog();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                MessageBox.Show(ex.Message, "異常A0013", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void tsmAutoTest1601_Click(object sender, EventArgs e)
        {
            try
            {
                FormSet1601 f = new FormSet1601(null);
                f.Show();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                MessageBox.Show(ex.Message, "異常A0072", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void 测试ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                List<ElectricViewModel> electricViewModels = new List<ElectricViewModel>();
                for(int i=0;i<100;i++)
                {
                    ElectricViewModel m = new ElectricViewModel();
                    electricViewModels.Add(m);
                }
                StandardView standardView = new StandardView();
                if (Settings.IsAllAuto())
                {
                    Form1601 f = new Form1601(this, null, 1, electricViewModels, standardView, null);
                    f.Show();
                }
                else
                {
                    var lcrForm = MachineFactory.GetLcrForm(this, null, 0, electricViewModels, standardView
                    , new GKQC.DbHelper.DbModels.ReportSetModel());
                    Form f = lcrForm as Form;
                    f.Show();
                }
            }
            catch(Exception ex)
            {
                Logger.LogError(ex);
                MessageBox.Show(ex.Message, "異常A0071", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                List<ElectricViewModel> electricViewModels = new List<ElectricViewModel>();
                for (int i = 0; i < 200; i++)
                {
                    ElectricViewModel m = new ElectricViewModel();
                    electricViewModels.Add(m);
                }
                StandardView standardView = new StandardView();
                if (Settings.IsAllAuto())
                {
                    Form1601 f = new Form1601(this, null, 1, electricViewModels, standardView, null);
                    f.Show();
                }
                else
                {
                    var f = new 
                        GKQC.Machine.FormLC2311(this, null, 6.3, electricViewModels, standardView
                            , new GKQC.DbHelper.DbModels.ReportSetModel());
                    f.Show();
                }


            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                MessageBox.Show(ex.Message, "異常A0071", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            try
            {
                List<ElectricViewModel> electricViewModels = new List<ElectricViewModel>();
                for (int i = 0; i < 20; i++)
                {
                    ElectricViewModel m = new ElectricViewModel();
                    electricViewModels.Add(m);
                }
                StandardView standardView = new StandardView();

                {
                    //var f = new
                    //    GKQC.Machine.FormLC2311Circle(this, null, 5, electricViewModels, standardView
                    //        , new GKQC.DbHelper.DbModels.ReportSetModel());
                    //f.Show();
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                MessageBox.Show(ex.Message, "異常A0071", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            try
            {
                List<ElectricViewModel> electricViewModels = new List<ElectricViewModel>();
                for (int i = 0; i < 10; i++)
                {
                    ElectricViewModel m = new ElectricViewModel();
                    electricViewModels.Add(m);
                }
                StandardView standardView = new StandardView();
                if (Settings.IsAllAuto())
                {
                    //Form1601Circle f = new Form1601Circle(this, null, 1, electricViewModels, standardView, null);
                    //f.Show();
                }
                else
                {
                    var lcrForm = MachineFactory.GetLcrForm(this, null, 0, electricViewModels, standardView
                    , new GKQC.DbHelper.DbModels.ReportSetModel());
                    Form f = lcrForm as Form;
                    f.Show();
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                MessageBox.Show(ex.Message, "異常A0071", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void toolStripMenuItemBoruikai_Click(object sender, EventArgs e)
        {
            try
            {
                //List<ElectricViewModel> electricViewModels = new List<ElectricViewModel>();
                //for (int i = 0; i < 100; i++)
                //{
                //    ElectricViewModel m = new ElectricViewModel();
                //    electricViewModels.Add(m);
                //}
                //StandardView standardView = new StandardView();
                //Form1601NoLc f = new Form1601NoLc(this, null, 1, electricViewModels, standardView, null);
                //f.Show();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                MessageBox.Show(ex.Message, "異常A0071", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
            try
            {
                List<ElectricViewModel> electricViewModels = new List<ElectricViewModel>();
                for (int i = 0; i < 100; i++)
                {
                    ElectricViewModel m = new ElectricViewModel();
                    electricViewModels.Add(m);
                }
                StandardView standardView = new StandardView();
                {
                    Form1601_20 f = new Form1601_20(this, null, 1, electricViewModels, standardView, null);
                    f.Show();
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                MessageBox.Show(ex.Message, "異常A0071", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                Environment.Exit(0);
            }
            catch(Exception ex)
            {

            }
        }
    }
}
